package com.wyr.proxyfactory;

import org.aopalliance.aop.Advice;
import org.springframework.aop.Pointcut;
import org.springframework.aop.PointcutAdvisor;
import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;

import java.lang.reflect.Method;

public class MyPointCutAdvisor implements PointcutAdvisor {
    @Override
    public Pointcut getPointcut() {
        return new StaticMethodMatcherPointcutAdvisor() {
            @Override
            public boolean matches(Method method, Class<?> targetClass) {
                return method.getName().equals("test");
            }
        };
    }

    @Override
    public Advice getAdvice() {
        return new MyCountMethodInterceptor();
    }

    @Override
    public boolean isPerInstance() {
        return true;
    }
}
